﻿function openMenu(menuID, linkObj) {
    if (um.ready) {
        //find co-ordinates of link object		
        var coords = {
            'x': um.getRealPosition(linkObj, 'x'),
            'y': um.getRealPosition(linkObj, 'y')
        }; 				//increase y-position to place it below the link	
        coords.y += (linkObj.offsetHeight - 4); 			//activate menu at returned co-ordinates		
        um.activateMenu(menuID, coords.x + 'px', coords.y + 'px');
    }
} //close menu with given ID


function closeMenu(menuID) {	//if the menu code is ready	
    if (um.ready) {		//deactive menu		
        um.deactivateMenu(menuID);
    }
}

function ConvertImageName(imageSource, conversionType) {
    if (conversionType == 'MOVER') {
        imageSource = imageSource.replace(".gif", "_roll.gif");
    }
    else if (conversionType == 'MOUT') {
        imageSource = imageSource.replace("_roll.gif", ".gif");
    }
    return imageSource;
}
function document.onmouseover() {
    var eSrc = window.event.srcElement;
    if (eSrc != null) {
        if ("clsMenuBarItem" == eSrc.className) {
            //Changing image name on mouse over event
            eSrc.src = ConvertImageName(eSrc.src, 'MOVER');
            //Opening the drop down menu corresponding to the selected main menu item
            openMenu(eSrc.id.replace("tdMenuBarItem", "divMenu"), eSrc);
        }
    }
}

function document.onmouseout() {
    var eSrc = window.event.srcElement;
    if (eSrc != null) {
        if ("clsMenuBarItem" == eSrc.className) {
            //Changing image name on mouse out event
            eSrc.src = ConvertImageName(eSrc.src, 'MOUT');
            //Closing the drodown menu
            closeMenu(eSrc.id.replace("tdMenuBarItem", "divMenu"));
        }
    }
}	
